package com.template.templateuser;

import org.apache.ibatis.javassist.ClassPool;
import org.apache.ibatis.javassist.CtClass;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

@SpringBootApplication
@MapperScan({
        "com.template.**.mapper"
})
@EnableFeignClients
@EnableResourceServer
@EnableRedisHttpSession
public class TemplateUserApplication {

    public static void main(String[] args) {

        SpringApplication.run(TemplateUserApplication.class, args);
    }
    /*@Bean
    public DataSource dataSource() throws FileNotFoundException, SQLException, IOException {
       // byte []bytes=new byte[10*1024];
        //new ClassPathResource("sharding-jdbc.yml").getInputStream().read(bytes);
        //new FileInputStream(new ClassPathResource("sharding-jdbc.yml").getInputStream());
        //ClassPathResource classPathResource = new ClassPathResource("static/something.txt");
        InputStream inputStream =  new ClassPathResource("sharding-jdbc.yml").getInputStream();
        File somethingFile = File.createTempFile("test", ".yml");
        try {
            org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream,somethingFile);
        } finally {
            IOUtils.closeQuietly(inputStream);

        }
        return MasterSlaveDataSourceFactory.createDataSource(somethingFile);

    }*/
    public void testJavaassist()throws Exception{
        ClassPool cp=ClassPool.getDefault();
        CtClass ctClass = cp.get("com.template.templateuser.domain.dto");

    }

}
